use "${clean}newspaper_analysis.dta", clear

// recoding Alexandria, VA to the South (technically part of DC until 1844)
replace south = 1 if city == "Alexandria"
replace north = 0 if city == "Alexandria"
replace state = "Virginia" if city == "Alexandria"

// dropping DC as a border area
drop if state == "District Of Columbia"

// keeping only the north
keep if north == 1

// standardizing variables
egen state_surban = std(state_urban_percent)
egen state_srugged = std(state_ruggedness)
egen state_spostoffice = std(state_postoffice_area)

// keeping the sample consistent
cap drop sample
gen sample = 1
foreach var of varlist $state_npcontrols {
	replace sample = . if `var' == .
}

// creating some variables
local c = 1860

gen period = year > `c'
replace year = year - `c'


* regressions
* ------------

estimates clear

xtset pub_id

// mcclellan baseline re model
eststo: xtreg singular c.year##i.period##i.lincoln_county ${state_npcontrols} if sample == 1, re cluster(pub_id)
estadd local fe "No"

// mcclellan baseline fe model
eststo: xtreg singular c.year##i.period##i.lincoln_county ${state_npcontrols} if sample == 1, fe cluster(pub_id)
estadd local fe "Publication"


// esttab
esttab est* using "${output}TabD16_np_lincoln_slopes_statecontrols_fulltable.tex", replace ///
	b(%8.3f) se(%8.3f) ///
	starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	scalars("fe Fixed Effects") ///
	keep( ///
		year ///
		1.period ///
		1.lincoln_county ///
		1.period#c.year ///
		1.lincoln_county#c.year ///
		1.period#1.lincoln_county ///
		1.period#1.lincoln_county#c.year ///
		state_surban state_spostoffice state_srugged state_anyriver state_anycanal _cons ///
		) ///
	order( ///
		year ///
		1.period ///
		1.lincoln_county ///
		1.period#c.year ///
		1.lincoln_county#c.year ///
		1.period#1.lincoln_county ///
		1.period#1.lincoln_county#c.year ///
		state_surban state_spostoffice state_srugged state_anyriver state_anycanal _cons ///
		) ///
	coeflabels( ///
		year "Year" ///
		1.period "After 1860" ///
		1.lincoln_county "Lincoln County" ///
		1.period#c.year "Year $\times$ After 1860" ///
		1.lincoln_county#c.year "Year $\times$ Lincoln County" ///
		1.period#1.lincoln_county "After 1860 $\times$ Lincoln County" ///
		1.period#1.lincoln_county#c.year "Year $\times$ After 1860 $\times$ Lincoln County" ///
		state_surban "State \% Urban (std)" ///
		state_spostoffice "State Post Office Density (std)" ///
		state_srugged "State Terrain Ruggedness (std)" ///
		state_anyriver "State on River" ///
		state_anycanal "State on Canal" ///
		_cons "Constant" ///
		) ///
	nodepvars nomtitles nonotes ///
	nogaps nolines posthead(\midrule) prefoot(\midrule) postfoot(\bottomrule \end{tabular}}) ///
	tex compress	
	

	
	



	

	
	
	







